//
//  MWCountryCodeCell.m
//  XiRan-iOS
//
//  Created by Richfit on 2020/3/17.
//  Copyright © 2020 Wood. All rights reserved.
//

#import "MWCountryCodeCell.h"

@interface MWCountryCodeCell ()

@property(nonatomic, strong) UILabel *titleLB;
@property(nonatomic, strong) UILabel *descLB;
@property(nonatomic, strong) UIImageView *arrowIV;
@property(nonatomic, strong) UIView *separatorView;

@end

@implementation MWCountryCodeCell

- (void)configData:(MWCountryCode *)countryCode {
    if ([[MWConfigManager manager].language isEqualToString:@"0"]) {
        _titleLB.text = countryCode.name_cn;
    } else if ([[MWConfigManager manager].language isEqualToString:@"2"]) {
        _titleLB.text = countryCode.name_ja;
    } else {
        _titleLB.text = countryCode.name_en;
    }
    _descLB.text = [NSString stringWithFormat:@"+%@", countryCode.code];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (!(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
        return nil;
    }

    [self setupPageSubviews];
    [self layoutPageSubviews];
    
    return self;
}

- (void)setupPageSubviews {
    _titleLB = [[UILabel alloc] init];
    _titleLB.font = MWFont(15);
    _titleLB.textColor = MWHexColor(@"#000000");
    [self.contentView addSubview:_titleLB];
    
    _descLB = [[UILabel alloc] init];
    _descLB.font = MWFont(15);
    _descLB.textColor = MWHexColor(@"#000000");
    [self.contentView addSubview:_descLB];
       
//    _arrowIV = [[UIImageView alloc] init];
//    _arrowIV.image = [UIImage imageNamed:@"ic_arrow_right"];
//    [self.contentView addSubview:_arrowIV];
    
    _separatorView = [[UIView alloc] init];
    _separatorView.backgroundColor = MWHexColor(@"#D8D8D8");
    [self.contentView addSubview:_separatorView];
}

- (void)layoutPageSubviews {
    [_titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(16);
        make.centerY.equalTo(self.contentView);
    }];
    
    [_descLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-16);
        make.centerY.equalTo(self.contentView);
    }];
    
//    [_arrowIV mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.equalTo(self.contentView).offset(-16);
//        make.centerY.equalTo(self.contentView);
//    }];
    
    [_separatorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.contentView);
        make.height.equalTo(@0.5);
    }];
}


@end
